package pers.qianyu.module.system.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.qianyu.module.core.comm.HttpResult;
import pers.qianyu.module.core.domain.system.dto.SysUserFollowDTO;
import pers.qianyu.module.logging.annotation.ControllerLog;
import pers.qianyu.module.logging.enums.BusinessType;
import pers.qianyu.module.system.service.SysUserFollowService;

/**
 * @author mizzle rain
 * @date 2021-04-07 15:16
 */
@Api(tags = "关注功能相关接口")
@RestController
@RequestMapping("/system-serv")
public class SysUserFollowController {
    @Autowired
    private SysUserFollowService sysUserFollowService;

    @ApiOperation("关注用户")
    @ControllerLog(businessType = BusinessType.ADD)
    @PostMapping("/follow")
    public HttpResult<?> addUserFollow(@Validated @RequestBody SysUserFollowDTO sysUserFollowDTO) {
        sysUserFollowService.insert(sysUserFollowDTO);
        return HttpResult.okWithMessage("关注成功");
    }

    @ApiOperation("取消关注用户")
    @ControllerLog(businessType = BusinessType.DELETE)
    @PostMapping("/cancel_follow")
    public HttpResult<?> cancelFollow(@RequestBody SysUserFollowDTO sysUserFollowDTO) {
        sysUserFollowService.delete(sysUserFollowDTO);
        return HttpResult.okWithMessage("取消关注成功");
    }
}
